<?php echo $this->headLink()->appendStylesheet($this->websiteUrl . 'system/css/seotoaster.css'); ?>
<?php echo $this->headLink()->appendStylesheet($this->websiteUrl . 'system/js/thickbox/thickbox.css'); ?>
<?php $this->headScript()->appendFile($this->websiteUrl . 'system/js/jquery/jquery.js'); ?>
<?php $this->headScript()->appendFile($this->websiteUrl . 'system/js/thickbox/thickbox.js'); ?>
<?php $this->headScript()->appendFile($this->websiteUrl . 'system/js/forms/forms.js'); ?>
<?php echo $this->headScript(); ?>
<script type="text/javascript">
    $(document).ready(function(){
/* $(".success").click(function(){hideMessages();});*/
$(".errors").click(function(){ hideMessages(); });
});
</script>
<?php if(isset($this->redirect) && $this->redirect!=""):   ?>
<script type="text/javascript">
    var tmpredirect = '<?php echo $this->redirect;?>';
    parent.tb_remove();
    top.location = tmpredirect;
</script>
<?php  endif; ?>
<div id="seotoaster" class="adminforms">
<?php /*if(isset($this->successSave)){  ?>
    <div class="success" ><strong>Form Successfuly Created.</strong></div>
<?php } */?>
<?php if(isset($this->errorElements)):  ?>
    <div class="errors" ><?php echo $this->errorElements;?></div>
<?php endif; ?>
<div id="admineditwhat">{%Add Form%} "<?php echo $this->name;?>"</div>
        <?php echo $this->form; ?>
<div class="close_window" onclick="parent.tb_remove();"></div>
<input type="hidden" id="hid-main-wsurl" name="hid-main-wsurl" value="<?php echo $this->websiteUrl; ?>" />
</div>
<style>
    .emptyListCC{
    position:absolute;
	width:50%;
	left:25%;
	right:25%;
	top:55%;
	text-align:center;
	padding:30px;
	opacity:0.75;
	color:#fff;
	border:1px solid #fff;
	-webkit-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.6);
	z-index:999;
	cursor:pointer;
	font-weight:bold;
	-moz-border-radius:15px;
	-webkit-border-radius:15px;
    background-color:#990000;
    }
    </style>
<script type="text/javascript">
	if($('#track').attr('checked')) {
		$('#tracking_details').show();
		$('#seotoaster.adminforms').css({'height' : '670px'});
	}
	$('#track').click(function() {
		$('#tracking_details').toggle();
		//console.log($('#seotoaster.adminforms').css('height'));
		var mainDiv = $('#seotoaster.adminforms');
		var mainDivHeight = mainDiv.css('height');
		if(mainDivHeight == '570px') {
			$('#seotoaster.adminforms').css({'height' : '670px'});
		}
		else {
			$('#seotoaster.adminforms').css({'height' : '570px'});
		}
	})
     $(document).ready(function(){
        $(".emptyList").click(function(){ $(".emptyListCC").hide(); });
        $('#constantContactBlok').hide();
        $('#showPropertiesCC').click(function(){
        $(".emptyList").empty();
        $('#ccListOfThemes').empty();
        $('#constantContactBlok').animate({opacity: 'toggle'}, 1200); 
        var urlAction = $("#websiteUrl").val()+"sys/backend_ajax/constantContactlist/";
        
      $.ajax({
            type: "POST",
            url: urlAction,
            dataType: "json",
            data: {
               constantContactLogin:$('input[name=constantContactLogin]').val(),
               constantContactPassword:$('input[name=constantContactPassword]').val(),
               constantContactApikey:$('input[name=constantContactApikey]').val()
                
            },
            success: function(msg){
                $('#ccListOfThemes').empty();
               $.each(msg, function(key, value) { 
                   if(value.id !=undefined){
                    $('#ccListOfThemes').append('<option value='+value.id+'>'+value.title+'</option>');
                   }
               });
               $('#ccList input').each(function(info){
                   var ccvalue = $(this).val();
                   $("#ccListOfThemes option[value='"+ccvalue+"']").attr("selected","selected"); 
                   
               
                });
                        
            },
            error: function(msgErr){
                
            }
            
            
            });
               
            return false;
        });
         
        $('#checkProperties').click(function(){
        $('#ccListOfThemes').empty();
        
        var urlAction = $("#websiteUrl").val()+"sys/backend_ajax/constantContactlist/";
        
      $.ajax({
            type: "POST",
            url: urlAction,
            dataType: "json",
            data: {
               constantContactLogin:$('input[name=constantContactLogin]').val(),
               constantContactPassword:$('input[name=constantContactPassword]').val(),
               constantContactApikey:$('input[name=constantContactApikey]').val()
                
            },
            success: function(msg){
                
                $(".emptyList").empty();
                    if (jQuery.type(msg) === "array"){
                                          
                
               $.each(msg, function(key, value) { 
                    
                    $('#ccListOfThemes').append('<option value='+value.id+'>'+value.title+'</option>');
                              
               });
               $('#ccList input').each(function(info){
                   var ccvalue = $(this).val();
                   $("#ccListOfThemes option[value='"+ccvalue+"']").attr("selected","selected"); 
                   
               
                });
                    }
                    else { $(".emptyList").append('<li class="emptyListCC" >'+msg+'</li>') }
                    
            },
            error: function(msgErr){
                
            }
            
            
            });
               
            return false;
        });
         
            
    });
</script>